<template>
  <view style="background-color: #F4F4F4; height: 100vh; padding: 20.83rpx">
    <Steps :options="refundInfo.successList" :active="refundInfo.active"></Steps>
  </view>
</template>

<script setup>
import { ref, getCurrentInstance } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import Steps from '@/components/step/steps'
const { $https } = getCurrentInstance().appContext.config.globalProperties
const refundInfo = ref({
  flag: true,
  active: 0,
  successList: [

  ]
})

const refundInfoId = ref(null)
onLoad((options) => {
  refundInfoId.value = options.id
  getRefundProgress()
})

const getRefundProgress = () => {
  refundInfo.value.successList = []
  $https({
    url: '/app/order/getRefundProgress',
    type: '',
    data: { refundInfoId: refundInfoId.value }
  }).then(res => {
    if (res.code === 0) {
      const isOkList = res.data.filter(f => ['2', '4', '5'].includes(f.authRemark))
      console.log(isOkList)
      res.data.forEach(item => {
        // eslint-disable-next-line eqeqeq
        const title = (item.authRemark == '1' && isOkList.length > 0) ? '客服审核通过' : item.title
        refundInfo.value.successList.push({
          title: title,
          descAndTime: item.descAndTime
        })
      })
      refundInfo.value.active = res.data.length

      // refundInfo.value.flag = !(res.data.filter(i => i.title === '审核失败').length > 0)
      // refundInfo.value.active = res.data.length + 1
      // refundInfo.value.successList.push(...refundInfo.value.successListSelect.slice(0, refundInfo.value.active + 0))
      // refundInfo.value.failList.push(...refundInfo.value.failListSelect.slice(0, refundInfo.value.active + 0))
      // res.data.forEach(item => {
      //   if (refundInfo.value.flag) {
      //     refundInfo.value.successList.forEach(info => {
      //       if (info.title === item.title) {
      //         info.descAndTime = item.descAndTime
      //       }
      //     })
      //   } else {
      //     refundInfo.value.failList.forEach(info => {
      //       if (info.title === item.title) {
      //         info.descAndTime = item.descAndTime
      //       }
      //     })
      //   }
      // })
    }
  })
}
</script>

<style scoped lang="scss">

</style>
